package tests.read;

import static org.junit.Assert.*;

import model.Budget;
import model.BudgetFactory;
import model.Line;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.workplicity.util.Helper;
import org.workplicity.worklet.WorkletContext;

public class LineQueryTest00
{
	Budget budget;
	BudgetFactory factory;
	Line line;

	@Before
	public void setUp() throws Exception
	{
		 factory = new BudgetFactory();
		 budget = (Budget) factory.create();
         budget.setName("Test budget");
         budget.setDescription("This is a test budget.");
         line = (Line) budget.createLine();
		 budget.add(line);
		 budget.commit();
	}

	@After
	public void tearDown() throws Exception
	{
		Helper.delete(line, WorkletContext.getInstance());
		Helper.delete(budget, WorkletContext.getInstance());
	}

	@Test
	public void test()
	{
		System.out.println("LQT00");
		try{
			Line l = (Line) Helper.fetch("Lines", line.getId(), WorkletContext.getInstance());
			if(!(l == null)){
				fail("Fetching budget by false id passed unexpectedly");
			}
			
		}
		catch (Exception e){
			fail("Fetching budget by false id failed with exception " + e);
		}
	}

}
